package leetcode_1_200;

public class LeeCode_152 {
    public static void main(String[] args) {
        System.out.println(findMin(new int[]{4, 5, 6, 7, 0, 1, 2}));
        System.out.println(findMin(new int[]{11,13,15,17}));
    }
    private static int findMin(int[] nums) {
        int l = 0;
        int r = nums.length - 1;
        while (l < r){
            int m = (l + r) / 2;
            int min = Math.min(nums[l], Math.min(nums[r], nums[m]));
            if (min == nums[l]){
                return nums[l];
            }else if (min == nums[m]){
                r = m;
            }else {
                l = m + 1;
            }
        }
        return nums[l];
    }
}
